package me.zk.practice1.thread;

/**
 * @Author: zhang kai
 * @Date: 2021/12/20
 * @Description:
 */
public class SingletonDemo {
    private static volatile SingletonDemo instance;

    private SingletonDemo() {
        System.out.println("SingletonDemo instance!");
    }
    public static SingletonDemo getInstance() {
        if (instance == null) {
            synchronized (SingletonDemo.class) {
                if (instance == null) {
                    instance = new SingletonDemo();
                }
            }
        }
        return instance;
    }
}
